#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
  pid_t it = fork();

  if(it == 0)
  {
    //child
    int cnt = 10;
    while(cnt)
    {
      printf("我是子进程:%d， 父进程%d，cnt:%d \n", getpid(), getppid(), cnt--);
      sleep(1);
    }
    exit(0); //进程退出
  }
  else if(it >= 0)
  {
    //father
    sleep(15);
    pid_t ret = wait(NULL);

    if(ret > 0)
    {
      printf("wait success：%d\n", ret);
    }
  }

  return 0;
}
